<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <link href="../css/element.css" rel="stylesheet"/>
    <link href="../css/styleindex.css" rel="stylesheet"/>
    <style>

    </style>
</head>
<body style="background:#EFF0F4;">

  <div class="mui-content">
    <div id="vm" class="x-examok" v-cloak>
      <div class="x-header-g" id="header">
        <a class="x-header-arrow" @click="api.closeWin()"></a>
        <div class="x-header-t">添加会议</div>
      </div>
      <!-- 员工资料 -->
      <div class="x-pro-list">
        <div class="x-pro-top">会议信息</div>
        <div class="x-pro-row">
          <div class="x-pro-label">会议时间:</div>
          <div class="x-pro-input">
            {{thtime}}
          </div>
        </div>
        <div class="x-pro-row">
          <div class="x-pro-label">参会人:</div>
          <div class="x-pro-input">
            {{thname}}
          </div>
        </div>
      </div>
      <!--  -->
      <div class="x-pro-list" v-for="(item,index) in prodata" :key="item.key">
        <div class="x-pro-top">会议提案{{index+1}}</div>
        <div class="x-pro-row x-pro-rowblock">
          <div class="x-pro-label">问题点描述:</div>
          <div class="x-pro-input">
            <el-input placeholder="请输入内容" v-model="item.problem" type="textarea" :rows="4" :disabled="isfromindex"></el-input>
          </div>
        </div>
        <div class="x-pro-row x-pro-rowblock">
          <div class="x-pro-label">提出建议:</div>
          <div class="x-pro-input">
            <el-input placeholder="请输入内容" v-model="item.proposal" type="textarea" :rows="4" :disabled="isfromindex"></el-input>
          </div>
        </div>
        <div class="x-pro-row">
          <div class="x-pro-label">提案人:</div>
          <div class="x-pro-input">
            {{mydata}}
          </div>
        </div>
        <div class="x-pro-remove" @click="removeentrywork(index)" v-show="!isfromindex">删除</div>
      </div>
      <!--  -->
      <div class="x-pro-addbox" @click="goonentrywork"  v-show="!isfromindex"><span class="x-pro-addicon"></span>添加提案</div>
      <!--  -->
      <div class="x-pro-gobtn" @click="gomeet" v-show="!isfromindex">提交</div>
    </div>
  </div>

  <script type="text/javascript" src="../script/vue.js"></script>
  <script type="text/javascript" src="../script/element.js"></script>
  <script type="text/javascript" src="../script/api.js"></script>
  <script type="text/javascript" src="../script/base.js"></script>
	<script>
apiready = function () {
    $api.fixStatusBar($api.byId('header'));
    var ismonth = api.pageParam.isfrommonth;
    var tid = api.pageParam.id;
    var ttime = api.pageParam.time;
    var tname = api.pageParam.name;

    //
    var vm = new Vue({
      el:'#vm',
      data(){
        return{
          prodata:[{
            'problem':'',
            'proposal':'',
            'memberid':'',
            'index':0
          }],
          isfromindex:false,
          thid:'',
          perdata:'',
          thtime:'',
          thname:'',
          entryworkindex:0,
          thismonth:false,
          mydata:''

        }
      },
      created:function() {
        var that=this;


      },
      mounted:function(){
        var that=this;
        that.mydata = $api.getStorage('username')
        //
        that.thid = tid;
        that.thtime = ttime;
        that.thname = tname;
        that.thismonth = ismonth;
        if(that.thismonth){//月
          that.backshowmonth()
        }else{//周
          that.backshow()
        }
        that.getperson()


      },
      methods: {
        //
        getperson:function(){
          let that=this;
          api.ajax({
            url:baseurl+'api/person/list',
            methods:'get',
            data:{
              values:{
                sec: $api.getStorage('apptoken')
              }
            }
          },function(ret,err){
            if(ret){
              api.hideProgress();
              console.log(JSON.stringify(ret));
              if(ret.status == 1){
                that.perdata = ret.data.list;

              }else{
                api.toast({
                    msg: ret.msg,
                    duration: 3000,
                    location: 'bottom'
                });
              }
            }else{
              api.hideProgress();
              console.log(JSON.stringify(err));
              api.toast({
                  msg: err.msg,
                  duration: 3000,
                  location: 'bottom'
              });
            }
          })
        },
        //删除
        removeentrywork:function(index){
          let that = this;
          var nowin = index;
          console.log(JSON.stringify(that.prodata));
          api.confirm({
            title: '操作提示',
            msg: '确定要删除吗？',
            buttons: ['确定','取消']
          }, function(ret, err) {
            var index = ret.buttonIndex;
            if(index == 1){
              //删除
              that.prodata.splice(nowin,1);//删除全部数组中对应的值
              console.log(JSON.stringify(that.prodata));
            }
          });
        },
        //继续添加
        goonentrywork:function(){
          var that = this;
          that.entryworkindex++
          that.prodata.push({
            'problem':'',
            'proposal':'',
            'memberid':'',
            'index':that.entryworkindex,
          });
        },
        //
        gomeet:function(){
          var that = this;
          if(that.thismonth){//月
            that.isokmonth()
          }else{//周
            that.isok()
          }
        },
        //提交 周
        isok:function(){
          var that = this;
          console.log(JSON.stringify(that.prodata));
          api.ajax({
            url:baseurl+'api/meeting/addWeekContent',
            methods:'get',
            data:{
              values:{
                sec: $api.getStorage('apptoken'),
                id:that.thid,
                content_json:that.prodata

              }
            }
          },function(ret,err){
            if(ret){
              api.hideProgress();
              console.log(JSON.stringify(ret));
              if(ret.status == 1){
                api.alert({
                    title: '提交成功',
                    msg: '',
                }, function(ret, err) {

                });

              }else{
                api.toast({
                    msg: ret.msg,
                    duration: 3000,
                    location: 'bottom'
                });
              }
            }else{
              api.hideProgress();
              console.log(JSON.stringify(err));
              api.toast({
                  msg: err.msg,
                  duration: 3000,
                  location: 'bottom'
              });
            }
          })
        },
        //提交 月
        isokmonth:function(){
          var that = this;
          console.log(JSON.stringify(that.prodata));
          api.ajax({
            url:baseurl+'api/meeting/addMonthContent',
            methods:'get',
            data:{
              values:{
                sec: $api.getStorage('apptoken'),
                id:that.thid,
                content_json:that.prodata

              }
            }
          },function(ret,err){
            if(ret){
              api.hideProgress();
              console.log(JSON.stringify(ret));
              if(ret.status == 1){
                api.alert({
                    title: '提交成功',
                    msg: '',
                }, function(ret, err) {

                });

              }else{
                api.toast({
                    msg: ret.msg,
                    duration: 3000,
                    location: 'bottom'
                });
              }
            }else{
              api.hideProgress();
              console.log(JSON.stringify(err));
              api.toast({
                  msg: err.msg,
                  duration: 3000,
                  location: 'bottom'
              });
            }
          })
        },
        //
        backshow:function(){
          var that = this;
          api.ajax({
            url:baseurl+'api/meeting/getWeekContent',
            methods:'get',
            data:{
              values:{
                sec: $api.getStorage('apptoken'),
                id:that.thid

              }
            }
          },function(ret,err){
            if(ret){
              api.hideProgress();
              console.log(JSON.stringify(ret));
              if(ret.status == 1){
                  that.prodata = ret.data.list;

              }else{
                api.toast({
                    msg: ret.msg,
                    duration: 3000,
                    location: 'bottom'
                });
              }
            }else{
              api.hideProgress();
              console.log(JSON.stringify(err));
              api.toast({
                  msg: err.msg,
                  duration: 3000,
                  location: 'bottom'
              });
            }
          })
        },
        //
        backshowmonth:function(){
          var that = this;
          api.ajax({
            url:baseurl+'api/meeting/getMonthContent',
            methods:'get',
            data:{
              values:{
                sec: $api.getStorage('apptoken'),
                id:that.thid

              }
            }
          },function(ret,err){
            if(ret){
              api.hideProgress();
              console.log(JSON.stringify(ret));
              if(ret.status == 1){
                  that.prodata = ret.data.list;

              }else{
                api.toast({
                    msg: ret.msg,
                    duration: 3000,
                    location: 'bottom'
                });
              }
            }else{
              api.hideProgress();
              console.log(JSON.stringify(err));
              api.toast({
                  msg: err.msg,
                  duration: 3000,
                  location: 'bottom'
              });
            }
          })
        },
      }
    })
	}


	</script>
</body>
</html>
